package com.khaled.protclass.featureselection.configuration;

import com.khaled.protclass.model.bean.protein.ProteinType;
import com.khaled.protclass.model.util.Constants;
import com.khaled.protclass.model.util.UtilDirectory;

/**
 * @author hassankh
 * Class bean for the input XML element. 
 */
public class Input
{
	private String class1_path;

	private String class2_path;

	private String output_path;

	private String relation_name;

	private ProteinType proteinType;

	/**
	 * @param class1_path
	 * @param class2_path
	 * @param output_path
	 * @param relationName
	 * @param proteinType
	 * @throws Exception 
	 */
	public Input(String class1_path, String class2_path, String output_path, String relationName,
			ProteinType proteinType) throws Exception
	{
		super();
		this.class1_path = class1_path;
		this.class2_path = class2_path;
		this.output_path = output_path;
		this.relation_name = relationName;
		this.proteinType = proteinType;
		
		validateClassPath(this.class1_path);
		
		validateClassPath(this.class2_path);
		
	}

	private void validateClassPath(String class_path) throws Exception
	{
		if(UtilDirectory.exist(class_path))
		{
			if(UtilDirectory.isFile(class_path) && this.proteinType.isStructure())
			{
				throw new Exception("The path: ["+class_path+"] is incorrect, Please enter correct path for structure proteins.");
			}
		}
		else
		{
			throw new Exception("The path: [ "+class_path+"] doesn't exist.");
		}
		
	}

	/**
	 * @return class1_path
	 */
	public String getClass1_path()
	{
		return class1_path;
	}

	/**
	 * @return class2_path
	 */
	public String getClass2_path()
	{
		return class2_path;
	}

	
	public String getOutput_path()
	{
		return output_path;
	}

	/**
	 * First validates on the input file path and then return the output path.
	 * @return output file path
	 */
	public String getOutputFilePath()
	{
		if (UtilDirectory.exist(output_path))
		{
			if (UtilDirectory.isFile(output_path))
			{
				return output_path;
			}
			else
			{
				return this.output_path + "\\" + this.relation_name + Constants.WEKA_FILE_EXT;
			}
		}
		return this.relation_name + Constants.WEKA_FILE_EXT;
	}

	/**
	 * @return proteinType
	 */
	public ProteinType getProteinType()
	{
		return proteinType;
	}

	/**
	 * @return relation_name
	 */
	public String getRelation_name()
	{
		return relation_name;
	}

}
